package com.giao.controller;

import com.giao.pojo.ExtCproductC;
import com.giao.service.jExtCproductService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/jExtCproduct")
public class jExtCproductController {
    @Resource
    private jExtCproductService jExtCproductService;

    //查询全部
    @RequestMapping("/findAlljExtCproduct")
    public String findAllJExtCproduct(Model model) {
        List<ExtCproductC> extCproductCS = jExtCproductService.findAllExtCproductC();
        model.addAttribute("jExt", extCproductCS);
        return "basicinfo/factory/jExtCproductCreate";
    }

    //跳转到添加页面
    @RequestMapping("/jExtCproductCreate")
    public String ToInsertjExtCproduct() {
        return "basicinfo/factory/jExtCproductCreate";
    }

    //添加方法
    @RequestMapping("/insertjExtCproduct")
    public String insertjExtCproduct(ExtCproductC extCproductC) {
        jExtCproductService.insertExtCproductC(extCproductC);
        return "redirect:/jExtCproduct/findAlljExtCproduct";
    }

    //跳转到修改页面
    @RequestMapping("/jExtCproductUpdate")
    public String jExtCproductUpdate(int id, Model model) {
        ExtCproductC extCproductC = jExtCproductService.findByExtCproductCId(id);
        model.addAttribute("jExtUp", extCproductC);
        return "basicinfo/factory/jExtCproductUpdate";
    }

    //修改
    @RequestMapping("/updatejExtCproduct")
    public String updatejExtCproduct(ExtCproductC extCproductC) {
        jExtCproductService.updateExtCproductC(extCproductC);
        return "redirect:/jExtCproduct/findAlljExtCproduct";
    }

    //删除
    @RequestMapping("/deletejExtCproduct/{ext_Cproduct_id}")
    public String deletejExtCproduct(@PathVariable("ext_Cproduct_id") int id) {
        jExtCproductService.deleteExtCproductC(id);
        return "redirect:/jExtCproduct/findAlljExtCproduct";
    }
}
